﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SRM;
using SRM.DataObjects;
using System.Data;

public partial class UserControls_FurtherInformationUserControl : System.Web.UI.UserControl, SRM.IUserInput
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Get AdditionPersonalParticulars()
            if (Page is IApplicantForm)
            {
                string applicantKey = string.Empty;
                applicantKey = ((IApplicantForm)Page).ApplicantKey;
                DataTable dt = SRM_Applicant.GetFurtherInformation(applicantKey);

                if ((dt != null) && (dt.Rows.Count > 0))
                {
                    System.Data.DataRow row = dt.Rows[0];
                    q1_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo1");
                    q2_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo2");
                    q3_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo3");
                    q4_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo4");
                    q5_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo5");
                    q6_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo6");
                    q7_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo7");
                    q8_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo8");
                    q9_radiobuttonlist.SelectedValue = row.Field<string>("FurtherInfo9");

                    q2_textbox.Text = row.Field<string>("FurtherInfo2Details");
                    q3_textbox.Text = row.Field<string>("FurtherInfo3Details");
                    q4_textbox.Text = row.Field<string>("FurtherInfo4Details");
                    q5_textbox.Text = row.Field<string>("FurtherInfo5Details");
                    q6_textbox.Text = row.Field<string>("FurtherInfo6Details");
                    q7_textbox.Text = row.Field<string>("FurtherInfo7Details");
                    q8_textbox.Text = row.Field<string>("FurtherInfo8Details");
                    q9_textbox.Text = row.Field<string>("FurtherInfo9Details");

                    //if ((row.Field<bool?>("ConsentDeclaration") != null) && (row.Field<bool?>("ConsentDeclaration").Value == true))
                    //{
                    //    cboDeclaration.Checked = true;
                    //}
                    //else
                    //{
                    //    cboDeclaration.Checked = false;
                    //}
                }
            }
        }
    }

    public void SaveUserInput()
    {
        string applicantKey = string.Empty;

        if (Page is IApplicantForm)
        {
            applicantKey = ((IApplicantForm)Page).ApplicantKey;
            SRM_Applicant.UpdateFurtherInformation(applicantKey,
                q1_radiobuttonlist.SelectedValue,
                q2_radiobuttonlist.SelectedValue,
                q3_radiobuttonlist.SelectedValue,
                q4_radiobuttonlist.SelectedValue,
                q5_radiobuttonlist.SelectedValue,
                q6_radiobuttonlist.SelectedValue,
                q7_radiobuttonlist.SelectedValue,
                q8_radiobuttonlist.SelectedValue,
                q9_radiobuttonlist.SelectedValue,
                q2_textbox.Text,
                q3_textbox.Text,
                q4_textbox.Text,
                q5_textbox.Text,
                q6_textbox.Text,
                q7_textbox.Text, 
                q8_textbox.Text,
                q9_textbox.Text);

                //dateofbirth_datepicker.SelectedDate,
                //race_combobox.SelectedValue,
                //maritalstatus_radcombobox.SelectedValue,
                //maritalstatussince_datepicker.SelectedDate,
                //gender_combobox.SelectedValue,
                //noofchildren_numerictextbox.Text,
                //dialect_radcombobox.SelectedValue,
                //religion_radcombobox.SelectedValue);
        }

        
    }
}
